import request from '../utils/request';

export const getRoleAll = () => {
	return request({
		url: '/roles',
		method: 'get',
	});
};

export const createRole = (query: RoleQuery) => {
	return request({
		url: '/roles',
		method: 'post',
		data: query,
	});
};

export const updateRole = (query: RoleQuery) => {
	return request({
		url: '/roles',
		method: 'put',
		data: query,
	});
};

export const deleteRole = (id: number) => {
	return request({
		url: '/roles',
		method: 'delete',
		data: { id },
	});
};

export const premissionRole = (roleUser: PremissionRole) => {
	return request({
		url: '/premission',
		method: 'post',
		data: roleUser,
	});
};

export const getPremissionAllByRoleId = async (roleId: number) => {
	return request({
		url: '/premission',
		method: 'get',
		params: { roleId },
	});
};
